package Reflection;

import java.lang.reflect.Field;

public class demo8 {
    public static void main(String[] args) throws NoSuchFieldException {
        Class c = Cat.class;
        //根据名字来获取变量对象
        Field fieldName = c.getField("name");
        System.out.println(fieldName.getName());

        Field fieldAge = c.getField("age");
        System.out.println(fieldAge.getName());
    }
}
